/**
 * 
 */
package admin.mode;

import base.Power;

/**
 * @author qsj
 *
 */
public class FunctionMode {
	
	public boolean leftmenu_save(Power power,AdminMode admin) throws Exception{
		
		String lm_name = power.getParameter("lm_name");
		String lm_uri = power.getParameter("lm_uri");
		String tm_id = power.getParameter("tm_id");
		String lm_sort = power.getParameter("lm_sort");
		String lm_perm = power.getParameter("lm_perm");
		
		String sql = "insert into houseclub_leftmenu set lm_name='"+lm_name+"',lm_uri='"+lm_uri+"',tm_id="+tm_id+",lm_sort='"+lm_sort+"',lm_perm='"+lm_perm+"'";

		if(power.executeUpdate(sql)>-1){
			return true;
		}
		return false;

	}
	
	public boolean leftmenu_update(Power power,AdminMode admin) throws Exception{
		
		String lm_id = power.getParameter("lm_id");
		String lm_name = power.getParameter("lm_name");
		String lm_uri = power.getParameter("lm_uri");
		String tm_id = power.getParameter("tm_id");
		String lm_sort = power.getParameter("lm_sort");
		String lm_perm = power.getParameter("lm_perm");
		
		String sql = "update houseclub_leftmenu set lm_name='"+lm_name+"',lm_uri='"+lm_uri+"',tm_id="+tm_id+",lm_sort='"+lm_sort+"',lm_perm='"+lm_perm+"' where lm_id="+lm_id;

		if(power.executeUpdate(sql)>-1){
			return true;
		}
		return false;

	}
	
	public boolean leftmenu_delete(Power power,AdminMode admin) throws Exception{
		String[] ids = power.getRequest().getParameterValues("ids");
		String str = base.tools.Tools.getStringFromStrings(ids,",");
		String sql = "delete from houseclub_leftmenu where lm_id in ("+str+")";
		if(power.executeUpdate(sql)>-1){
			return true;
		}
		return false;
	}
	
	
	
	public boolean topmenu_save(Power power,AdminMode admin) throws Exception{
		
		String tm_name = power.getParameter("tm_name");
		String tm_uri = power.getParameter("tm_uri");
		String tm_sort = power.getParameter("tm_sort");
		String tm_perm = power.getParameter("tm_perm");
		
		String sql = "insert into houseclub_topmenu set tm_name='"+tm_name+"',tm_uri='"+tm_uri+"',tm_sort='"+tm_sort+"',tm_perm='"+tm_perm+"'";

		if(power.executeUpdate(sql)>-1){
			return true;
		}
		return false;

	}
	
	public boolean topmenu_update(Power power,AdminMode admin) throws Exception{
		
		String tm_id = power.getParameter("tm_id");
		String tm_name = power.getParameter("tm_name");
		String tm_uri = power.getParameter("tm_uri");
		String tm_sort = power.getParameter("tm_sort");
		String tm_perm = power.getParameter("tm_perm");
		
		String sql = "update houseclub_topmenu set tm_name='"+tm_name+"',tm_uri='"+tm_uri+"',tm_sort='"+tm_sort+"',tm_perm='"+tm_perm+"' where tm_id="+tm_id;

		if(power.executeUpdate(sql)>-1){
			return true;
		}
		return false;

	}
	
	public boolean topmenu_delete(Power power,AdminMode admin) throws Exception{
		String[] ids = power.getRequest().getParameterValues("ids");
		String str = base.tools.Tools.getStringFromStrings(ids,",");
		String sql = "delete from houseclub_topmenu where tm_id in ("+str+")";
		if(power.executeUpdate(sql)>-1){
			return true;
		}
		return false;
	}
}
